package com.xly.webclick.cusview.fontview;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;

import com.xly.webclick.R;
import com.xly.webclick.utils.FontTypeManager;


/**
 * Created by amos on 2018/5/5.
 */

public class FontTextView extends AppCompatTextView {

    public FontTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.FontTextView);
        if (typedArray != null) {

            int type = typedArray.getInt(R.styleable.FontTextView_ftv_fontType, 0);

            switch (type) {
                case 1:
                    setTypeface(FontTypeManager.getRobotoMedium(context.getAssets()));
                    break;
                case 2:
                    setTypeface(FontTypeManager.getRobotoRegular(context.getAssets()));
                    break;
                case 3:
                    setTypeface(FontTypeManager.getRobotoBold(context.getAssets()));
                    break;
                case 4:
                    setTypeface(FontTypeManager.getRobotoBlack(context.getAssets()));
                    break;
            }

            typedArray.recycle();
        }

    }
}
